package towerDefense.towers;

import com.golden.gamedev.object.SpriteGroup;
import com.golden.gamedev.object.Timer;
import towerDefense.circlesprites.CircleSpriteGroup;


public class TowerSpriteGroup extends CircleSpriteGroup
{
    private Timer scanFrequence = new Timer(15000);
    private SpriteGroup myProjectiles;


    @Override
    public void update (long elapsedTime)
    {
        for (int i = 0; i < this.getSize(); i++)
        {
            if (this.getSprites()[i].isActive())
            {
                ((TowerSprite) this.getSprites()[i]).update(elapsedTime,
                                                            myProjectiles);
            }
        }

        if (this.scanFrequence.action(elapsedTime))
        {
            // remove all inactive sprites
            this.removeInactiveSprites();
        }
    }


    public TowerSpriteGroup (String name, SpriteGroup projectiles)
    {
        super(name);
        myProjectiles = projectiles;
    }


    public TowerSprite[] getTowerSprites ()
    {
        TowerSprite[] ts = new TowerSprite[super.getSprites().length];
        for (int i = 0; i < ts.length; i++)
        {
            System.out.println("is adding a sprite poo");
            ts[i] = (TowerSprite) super.getSprites()[i];
        }
        return ts;
    }

}
